package com.android.jay.lib_audio.mediaplayer.model;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import com.android.jay.lib_audio.mediaplayer.db.DaoSession;
import com.android.jay.lib_audio.mediaplayer.db.AudioBeanDao;
import com.android.jay.lib_audio.mediaplayer.db.FavouriteDao;

/**
 * Created by wzp on 2020/1/31 0031.
 * <p>
 * 描述  ：收藏实体类
 */
@Entity
public class Favourite {

    @Id(autoincrement = true)
    Long favouriteId;
    @NotNull
    String audioId;
    //一条收藏记录唯一对应一条实体
    @ToOne
    AudioBean audioBean;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 1743949577)
    private transient FavouriteDao myDao;
    @Generated(hash = 1445024019)
    public Favourite(Long favouriteId, @NotNull String audioId) {
        this.favouriteId = favouriteId;
        this.audioId = audioId;
    }
    @Generated(hash = 1933414424)
    public Favourite() {
    }
    public Long getFavouriteId() {
        return this.favouriteId;
    }
    public void setFavouriteId(Long favouriteId) {
        this.favouriteId = favouriteId;
    }
    public String getAudioId() {
        return this.audioId;
    }
    public void setAudioId(String audioId) {
        this.audioId = audioId;
    }
    @Generated(hash = 2031896487)
    private transient boolean audioBean__refreshed;
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1416966049)
    public AudioBean getAudioBean() {
        if (audioBean != null || !audioBean__refreshed) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            AudioBeanDao targetDao = daoSession.getAudioBeanDao();
            targetDao.refresh(audioBean);
            audioBean__refreshed = true;
        }
        return audioBean;
    }
    /** To-one relationship, returned entity is not refreshed and may carry only the PK property. */
    @Generated(hash = 1081820565)
    public AudioBean peakAudioBean() {
        return audioBean;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1259146766)
    public void setAudioBean(AudioBean audioBean) {
        synchronized (this) {
            this.audioBean = audioBean;
            audioBean__refreshed = true;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1142028328)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getFavouriteDao() : null;
    }
}
